/**
 * Created by dale on 2017/10/17.
 */
var targetObj;
$(document).ready(function () {

    var form = new xhForm($('#xh_form'));

    $(".form-date").datetimepicker({format: 'yyyy-mm-dd', language: 'zh-CN', autoclose: true});




    if(noticeInfo!='1'){
        form.fill(noticeInfo);
        $('#cc').combotree({
            url:baseUrl+'frontend/msg/getDepStaff',
            valueField:'id',
            textField:'text',
            required:false,
            multiple: true,
            width:'360px',
            height:'34px',
            panelHeight:'300px',
            onLoadSuccess:function (data) {
                $('#cc').combotree('setValues',noticeInfo['sNoticeIds']);
            }
        });
    }else {
        $('#cc').combotree({
            url:baseUrl+'frontend/msg/getDepStaff',
            valueField:'id',
            textField:'text',
            required:false,
            multiple: true,
            width:'360px',
            height:'34px',
            panelHeight:'300px'
        });
    }

    form.parse().bindRequired($('#bt_modal_confirm',parent.document));


    $('#bt_modal_confirm',parent.document).click(function () {
        $('[name="sNoticeIds"]').val($('#cc').combotree("getValues"));
        $.ajax({
            url:baseUrl+'frontend/msg/saveNotice',
            data:$('#xh_form').serialize(),
            type:'POST',
            success:function (data) {
                $('#bt_modal_confirm',parent.document).addClass('disabled');
                window.top.xhTop.closeModal();
                window.top.xhTop.getActiveFrame().noticeList.datagrid('reload');

            },
            error:function (data) {
                console.log(data);
            }
        });

    });

    
    

});
